﻿#include "wmountnode.h"
#include "wnodemanager.h"
#include "wxpolygonex.h"
#include "../common.h"

WMountNode::WMountNode()
{
    this->setNodeType(NODE_MOUNT);
}

WMountNode::WMountNode(const wxString& pname)
    : WBaseNode(pname)
{
    this->setNodeType(NODE_MOUNT);
}

WMountNode::~WMountNode()
{

}

/// 工作区域改变
void WMountNode::changeWorkingRect(wxRect workingrect)
{
    WBaseNode::changeWorkingRect(workingrect);

    // 计算实际显示点
    mScreenCenterPosition = wxRealPoint(workingrect.GetLeftTop().x+workingrect.GetWidth()*(mCenterPosition.x/100.0f),
                              workingrect.GetLeftTop().y+workingrect.GetHeight()*(mCenterPosition.y/100.0f));

    int tmpWidth = IDD_MOUNTPOINT_WIDTH/2;
    int tmpHeight = IDD_MOUNTPOINT_HEIGHT/2;

    // 计算包围盒
    wxPoint points[4];
    points[0] = wxPoint(mScreenCenterPosition.x-tmpWidth,mScreenCenterPosition.y-tmpHeight);
    points[1] = wxPoint(mScreenCenterPosition.x+tmpWidth,mScreenCenterPosition.y-tmpHeight);
    points[2] = wxPoint(mScreenCenterPosition.x+tmpWidth,mScreenCenterPosition.y+tmpHeight);
    points[3] = wxPoint(mScreenCenterPosition.x-tmpWidth,mScreenCenterPosition.y+tmpHeight);

    this->setBoundingRect(wxPolygonEx(4,points));
}

/// 更新
void WMountNode::update(void)
{

}
